package com.isoft.dao.blls;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.isoft.entity.ball.Blls;
import com.isoft.entity.flight.FlightInfo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.io.Serializable;
import java.util.List;

/**
 * 行李的数据层
 */
@Mapper
public interface BllsDao extends BaseMapper<Blls> {
//    通过ID查询
    @Select("select ID,META_ID,BTNO,CODE,ESTR,EEND,VALID from TEAM04.DFME_BLLS_BELT where ID=#{ID}")
    Blls selectBllsByID(Integer ID);
    //查询所有
    @Select(" SELECT B.META_ID,B.BTNO,B.ID,B.CODE,B.ESTR,B.EEND ,B.VALID" +
            " FROM TEAM04.COMMON_META AS C " +
            " JOIN TEAM04.DFME_BLLS_BELT AS B " +
            " ON B.META_ID = C.SEQN;")
    List<Blls> findAllBlls();
    //根据航班号【SEQN】查询所有信息
    @Select("select ID,META_ID,BTNO,CODE,ESTR,EEND ,VALID FROM TEAM04.DFME_BLLS_BELT where META_ID =#{METAID}")
    List<Blls> findBllsBySEQN(Integer METAID);
    //添加
    @Override
    int insert(Blls blls);
//修改
    @Update("<script>UPDATE TEAM04.DFME_BLLS_BELT " +
            "<set>" +
            "<if test='BTNO != null'>BTNO = #{BTNO},</if>" +
            "<if test='CODE != null'>CODE = #{CODE},</if>" +
            "<if test='ESTR != null'>ESTR = #{ESTR},</if>" +
            "<if test='EEND != null'>EEND = #{EEND},</if>" +
            "<if test='VALID != null'>VALID = #{VALID},</if>" +
            "</set>" +
            "WHERE ID = #{ID}</script>")
    int update(Blls blls);

    @Override
    int deleteById(Blls ID);

    //    分页查询
    List<Blls> selectList(@Param("ew") Wrapper<Blls> queryWrapper);

}

